FrameLib  2.0
DSP processing with frames of arbitrary timing and length
FrameLib_ProcessingQueue.h
Go to the documentation of this file.
1 
2 #ifndef FRAMELIB_PROCESSINGQUEUE_H
3 #define FRAMELIB_PROCESSINGQUEUE_H
4 
5 #include "FrameLib_Types.h"
6 #include "FrameLib_Errors.h"
7 
8 #include <chrono>
9 
10 // Forward Declarations
11 
12 class FrameLib_DSP;
13 
31 {
40  class IntervalSecondsClock
41  {
42 
43  public:
44 
45  void start() { mStartTime = getTime(); }
46  long long elapsed() { return std::chrono::duration_cast<std::chrono::seconds>(getTime() - mStartTime).count(); }
47 
48  private:
49 
50  std::chrono::steady_clock::time_point getTime() { return mClock.now(); }
51 
52  std::chrono::steady_clock mClock;
53  std::chrono::steady_clock::time_point mStartTime;
54  };
55 
56  static const int sProcessPerTimeCheck = 200;
57  static const int sMaxTime = 5;
58 
59 public:
60 
61  FrameLib_ProcessingQueue(FrameLib_ErrorReporter& errorReporter) : mTop(nullptr), mTail(nullptr), mTimedOut(false), mErrorReporter(errorReporter) {}
62 
63  // Non-copyable
64 
67 
68  void add(FrameLib_DSP *object);
69  void reset() { mTimedOut = false; }
70  bool isTimedOut() { return mTimedOut; }
71 
72 private:
73 
74  FrameLib_DSP *mTop;
75  FrameLib_DSP *mTail;
76 
77  bool mTimedOut;
78  IntervalSecondsClock mClock;
79 
80  FrameLib_ErrorReporter& mErrorReporter;
81 };
82 
83 #endif /* FRAMELIB_PROCESSINGQUEUE_H */
an abstract class containing the core of the DSP processing system, which handles single-stream sched...
Definition: FrameLib_DSP.h:25
a class used to report errors to the host environment.
Definition: FrameLib_Errors.h:34
bool isTimedOut()
Definition: FrameLib_ProcessingQueue.h:70
FrameLib_ProcessingQueue(FrameLib_ErrorReporter &errorReporter)
Definition: FrameLib_ProcessingQueue.h:61
a minimal processing queue that is used to non-recursively process FrameLIB_DSP objects in a network...
Definition: FrameLib_ProcessingQueue.h:30
void add(FrameLib_DSP *object)
Definition: FrameLib_ProcessingQueue.cpp:5
FrameLib_ProcessingQueue & operator=(const FrameLib_ProcessingQueue &)=delete
void reset()
Definition: FrameLib_ProcessingQueue.h:69